Fix channel order bug and make select_channels private - #4712
Fix channel order bug and make select_channels private#4712chrishalcrow wants to merge 11 commits into
select_channels private#4712Conversation
alejoe91
left a comment
There was a problem hiding this comment.
Another couple of minor comments :)
| channel_indices = [] | ||
| unit_channel_ids = old_unit_id_to_channel_ids[unit_id] | ||
|
|
||
| for channel_id in channel_ids: | ||
| if channel_id in unit_channel_ids: | ||
| idx = np.where(old_unit_id_to_channel_ids[unit_id] == channel_id)[0][0] | ||
| channel_indices.append(idx) |
There was a problem hiding this comment.
| channel_indices = [] | |
| unit_channel_ids = old_unit_id_to_channel_ids[unit_id] | |
| for channel_id in channel_ids: | |
| if channel_id in unit_channel_ids: | |
| idx = np.where(old_unit_id_to_channel_ids[unit_id] == channel_id)[0][0] | |
| channel_indices.append(idx) | |
| unit_channel_ids = old_unit_id_to_channel_ids[unit_id] | |
| channel_ids_in_unit = [ch for ch in channel_ids if channel_id in unit_channel_ids] | |
| channel_indices = self.sorting_analyzer.channel_ids_to_indices(channel_ids_in_unit) |
I think that this does the exact same thing, right?
There was a problem hiding this comment.
You need the old channel_ids_to_indices, not the new ones from self.sorting_analyzer.channel_ids_to_indices
There was a problem hiding this comment.
self is the old analyzer, no?
See:
old_waveforms = self.data["waveforms"]
There was a problem hiding this comment.
Oop - we're both wrong. The channel_indices tell you how to map between the channel_indices with respect to the sparsity mask for each unit (no the overall channel_indices). You can make the code look very simple if you have access to the new sorting_analyzer's sparsity mask, which we don't easily have.
I've updated the variables names, which I think should help avoid confusion.
| channel_indices = [] | ||
| unit_channel_ids = old_unit_id_to_channel_ids[unit_id] | ||
|
|
||
| for channel_id in channel_ids: | ||
| if channel_id in unit_channel_ids: | ||
| idx = np.where(old_unit_id_to_channel_ids[unit_id] == channel_id)[0][0] | ||
| channel_indices.append(idx) |
There was a problem hiding this comment.
| channel_indices = [] | |
| unit_channel_ids = old_unit_id_to_channel_ids[unit_id] | |
| for channel_id in channel_ids: | |
| if channel_id in unit_channel_ids: | |
| idx = np.where(old_unit_id_to_channel_ids[unit_id] == channel_id)[0][0] | |
| channel_indices.append(idx) | |
| unit_channel_ids = old_unit_id_to_channel_ids[unit_id] | |
| channel_ids_in_unit = [ch for ch in channel_ids if channel_id in unit_channel_ids] | |
| channel_indices = self.sorting_analyzer.channel_ids_to_indices(channel_ids_in_unit) |
same here
Fixes a channel order bug in the sparsity mask for the new
select_channelsmethod for analyzers.Discussed with @alejoe91 and decided to keep this method private for now - we hope users will access through the
split_bymethod rather than directly.Fixed waveforms and pca selection.
Todo: add tests for waveforms and pca.